<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<base href="<%=basePath%>">

<html>
<head>
    <meta charset="utf-8">
    <title>
        阳光成单系统
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="System/css/x-admin.css" media="all">


    <%--<link rel="stylesheet" href="System/css/reset.css" />
    <link rel="stylesheet" href="System/css/demo.css" />--%>

    <!-- jqPagination styles -->
    <link rel="stylesheet" href="System/css/jqpagination.css" />

    <%--<!-- scripts -->
    <script src="System/js/jquery-1.7.2.min.js"></script>
    <script src="System/js/jquery.jqpagination.js"></script>
    <script src="System/js/scripts.js"></script>

    <!-- generic demo script -->
    <script src="System/js/demo.js"></script>--%>

</head>
<style>
    #begin,#upper,#lower,#end{
        width: 40px;
        height: 30px;
        font-size: 20px;
    }
    #a{
        width: 200px;
        height: 30px;
        font-size: 18px;
    }
</style>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>会员管理</cite></a>
              <a><cite>系统词典</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="goods/queryStateLimit?page=1&state=2" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form x-center" action="" style="width:70%">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width:60px">货物编号</label>
                <div class="layui-input-inline" style="width:120px">
                    <input type="text" name="name"  placeholder="请输入货物编号" autocomplete="off" class="layui-input">
                </div>

                <div class="layui-input-inline" style="width:80px">
                    <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>搜索</button>
                </div>


                <label class="layui-form-label" style="width:60px">货物名称</label>
                <div class="layui-input-inline" style="width:120px">
                    <input type="text" name="name1"  placeholder="请输入货物名称" autocomplete="off" class="layui-input">
                </div>


                <div class="layui-input-inline" style="width:80px">
                    <button class="layui-btn"  lay-submit="" lay-filter="sreach1"><i class="layui-icon">&#xe615;</i>搜索</button>
                </div>

                <label class="layui-form-label" style="width:60px">货物类别</label>
                <div class="layui-input-inline" style="width:120px">
                    <select name="tablename" id="sel" lay-filter="sel">
                        <option value="">选择货物类别</option>
                        <c:forEach items="${goodsTypeList}" var="goodsType">
                            <option value="${goodsType.goodstypeType}">${goodsType.goodstypeType}</option>
                        </c:forEach>
                    </select>
                </div>

            </div>
        </div>
    </form>
    <xblock><button onclick="delAll()" class="layui-btn" lay-submit="" lay-filter="sreach">批量分拣</button><span class="x-right" style="line-height:40px">共有数据：${count} 条</span></xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <input type="checkbox" name="" value="">
            </th>
            <th>
                货物编号
            </th>
            <th>
                货物名称
            </th>
            <th>
                货物数量
            </th>
            <th>
                货物重量
            </th>
            <th>
                收货地址
            </th>
            <th>
                货物类别
            </th>
            <th>
                所在仓库位置
            </th>
            <th>
                货物状态
            </th>
            <th>
                操作
            </th>
        </tr>
        </thead>
        <tbody id="tbody">
        <c:forEach items="${goods}" var="good">
            <tr>
                <td>
                    <input type="checkbox" value="${good.goodsId}" name="">
                </td>
                <td>
                    <input type="hidden" id="address" value="${good.location.area["areaMark"]}">
                        ${good.goodsOrders}
                </td>
                <td>
                        ${good.goodsName}
                </td>
                <td>
                        ${good.goodsNumber}
                </td>
                <td>
                        ${good.goodsWeight}
                </td>
                <td>
                        ${good.userAddress}
                </td>
                <td>
                        ${good.goodstype["goodstypeType"]}
                </td>
                <td>
                        ${good.location["locationNumber"]}
                </td>
                <td>
                        ${good.goodsState==2?"分拣完成":""}
                </td>
                <td class="td-manage">
                    <button onclick="goodsState(${good.goodsId})" class="layui-btn" style="height: 30px;line-height: 13px;"  lay-submit="" lay-filter="">出库</button>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<%--    分页--%>
<div id="wrapper" style="margin-top: -10px;margin-left:480px">
    <div class="pagination">
        <a href="javascript:;" onclick="begin1()"  id="begin" class="first" data-action="first">&laquo;</a>
        <a href="javascript:;" onclick="upper1()"  id="upper" class="previous" data-action="previous">&lsaquo;</a>
        <input type="text" id="a"  readonly="readonly" value="${pageText}"/>
        <input type="hidden" id="a1" readonly="readonly" value="${thisPage}">
        <a href="javascript:;"  onclick="lower1()" id="lower" class="next" data-action="next">&rsaquo;</a>
        <a href="javascript:;" onclick="end1()"  id="end" class="last" data-action="last">&raquo;</a>
    </div>
    <div class="clearfix"></div> <!-- should probably have a shower after that -->
    <div style="text-align:center;clear:both;margin-top:50px">
        <%--    <script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>--%>
        <%--    <script src="/follow.js" type="text/javascript"></script>--%>
    </div>
</div>
<script src="System/lib/layui/layui.js" charset="utf-8"></script>
<script src="System/js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();

        //下拉列表值改变时
        form.on('select(sel)',function (data) {
            console.log(data.value);
            location.href="goods/queryStateSelect?state=2&str="+data.value+"&page=1";
            // console.log(data.elem[data.elem.selectedIndex].text);
            // if(data.elem[data.elem.selectedIndex].text=="全部数据"){
            //     location.href="ArticleInfoAll?number=0";
            // }else{
            //     location.href="labelTitleQuery?id="+data.value;
            // }
        })

        //监听提交
        form.on('submit(sreach)', function(data){
            console.log(data);
            location.href="goods/queryStateLike?state=2&state1=1&str="+data.field.name+"&page=1";
            //LikeQuery
            //发异步，把数据提交给php
            // layer.alert("增加成功", {icon: 6});
            // $('#x-link').prepend('<tr><td><input type="checkbox"value="1"name=""></td><td>1</td><td>1</td><td>'+data.field.name+'</td><td class="td-manage"><a title="编辑"href="javascript:;"onclick="cate_edit(\'编辑\',\'cate-edit.html\',\'4\',\'\',\'510\')"class="ml-5"style="text-decoration:none"><i class="layui-icon">&#xe642;</i></a><a title="删除"href="javascript:;"onclick="cate_del(this,\'1\')"style="text-decoration:none"><i class="layui-icon">&#xe640;</i></a></td></tr>');
            return false;
        });

        //监听提交
        form.on('submit(sreach1)', function(data){
            console.log(data);
            location.href="goods/queryStateLike?state=2&state1=0&str="+data.field.name1+"&page=1";
            //LikeQuery
            //发异步，把数据提交给php
            // layer.alert("增加成功", {icon: 6});
            // $('#x-link').prepend('<tr><td><input type="checkbox"value="1"name=""></td><td>1</td><td>1</td><td>'+data.field.name+'</td><td class="td-manage"><a title="编辑"href="javascript:;"onclick="cate_edit(\'编辑\',\'cate-edit.html\',\'4\',\'\',\'510\')"class="ml-5"style="text-decoration:none"><i class="layui-icon">&#xe642;</i></a><a title="删除"href="javascript:;"onclick="cate_del(this,\'1\')"style="text-decoration:none"><i class="layui-icon">&#xe640;</i></a></td></tr>');
            return false;
        });

    })

    //加入分拣
    function goodsState(goodsId) {
        //定义变量 用于提示
        var str="确认出库吗?";
        //提示是否确认分拣
        layer.confirm(str,function(index){
            location.href="goods/updateState?goodId="+goodsId+"&state=2&address="+$("#address").val();
        });
    }

    //批量删除提交
    function delAll () {
        var checks = $('#tbody').find('input[type=checkbox]:checked');
        var str="";
        for (var i = 0; i < checks.length; i++) {
            str+=checks[i].value+",";
        }
        layer.confirm('确认出库选中的货物吗？',function(index){
            //捉到所有被选中的，发异步进行删除  提示
            // layer.msg('操作成功!', {icon: 1});
            //ajax请求   软删除选中文章数据
            $.post("goods/updateStateAll", {str:str,state:2,address:$("#address").val()}, function () {
                window.location.reload();
            });
        });
    }

    //-编辑
    function data_edit (title,url,id,w,h) {
        x_admin_show(title,url,w,h);
    }

    /*-删除*/
    function data_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }

    //首页
    function begin1(){
        $("#a1").attr("value",1);
        var number=$("#a1").val();
        /*queryLikeName不为空的时候   属于模糊查询的分页*/
        <c:if test="${not empty queryLikeName}">
        location.href="goods/queryStateLike?state=2&state1=0&str="+"${queryLikeName}"+"&page="+number;
        </c:if>
        /*queryLikeName为空的时候   属于全部数据的分页*/
        <c:if test="${empty queryLikeName}">
        location.href="goods/queryStateLimit?page="+number+"&state=2";
        </c:if>
    }
    //上一页
    function upper1(){
        if(parseInt($("#a1").val())<=1){
            $("#a1").val().attr("value",1);
        }
        $("#a1").attr("value",parseInt($("#a1").val())-1);
        var number=$("#a1").val();
        /*queryLikeName不为空的时候   属于模糊查询的分页*/
        <c:if test="${not empty queryLikeName}">
        location.href="goods/queryStateLike?state=2&state1=0&str="+"${queryLikeName}"+"&page="+number;
        </c:if>
        /*queryLikeName为空的时候   属于全部数据的分页*/
        <c:if test="${empty queryLikeName}">
        location.href="goods/queryStateLimit?page="+number+"&state=2";
        </c:if>
    }
    //下一页
    function lower1(){
        if(parseInt($("#a1").val())>=${goodPageMax}){
            $("#a1").val().attr("value",${goodPageMax});
        }
        $("#a1").attr("value",parseInt($("#a1").val())+1);
        //console.log($("#a").val());
        var number=$("#a1").val();
        /*queryLikeName不为空的时候   属于模糊查询的分页*/
        <c:if test="${not empty queryLikeName}">
        location.href="goods/queryStateLike?state=2&state1=0&str="+"${queryLikeName}"+"&page="+number;
        </c:if>
        /*queryLikeName为空的时候   属于全部数据的分页*/
        <c:if test="${empty queryLikeName}">
        location.href="goods/queryStateLimit?page="+number+"&state=2";
        </c:if>
    }
    //尾页
    function end1(){
        $("#a1").attr("value",${goodPageMax});
        var number=$("#a1").val();
        /*queryLikeName不为空的时候   属于模糊查询的分页*/
        <c:if test="${not empty queryLikeName}">
        location.href="goods/queryStateLike?state=2&state1=0&str="+"${queryLikeName}"+"&page="+number;
        </c:if>
        /*queryLikeName为空的时候   属于全部数据的分页*/
        <c:if test="${empty queryLikeName}">
        location.href="goods/queryStateLimit?page="+number+"&state=2";
        </c:if>
    }

</script>

</body>
</html>

<%--
    // 获得frame索引
    var index = parent.layer.getFrameIndex(window.name);
    //关闭当前frame
    parent.layer.close(index);
--%>